<?php

/**
 * Description of AppMenus
 * Indonesian Brains Solutions
 * @author sony wibisono
 * E-mail : sony@sonywibisono.com
 */
class AppMenus {
var $id;
var $caption;
var $tool_tips;
var $grant_admin;
var $enabled;
var $icon_url;
var $menu_url;
var $modules;

    function __construct($id,$caption,$tool_tips,$grant_admin,$enabled,$icon_url,$menu_url,$modules) {
        $this->id=$id;
        $this->caption=$caption;
        $this->tool_tips=$tool_tips;
        $this->grant_admin=$grant_admin;
        $this->enabled=$enabled;
        $this->icon_url=$icon_url;
        $this->menu_url=$menu_url;
        $this->modules=$modules;
    }

    function open(){
        global $db;
        $sql="select * from app_menus where id=$id";
        $row=$db->fetch_row($sql);
        if (!empty($row)){
            extract($row);
            $this->caption=$caption;
            $this->tool_tips=$tool_tips;
            $this->grant_admin=$grant_admin;
            $this->enabled=$enabled;
            $this->icon_url=$icon_url;
            $this->menu_url=$menu_url;
            $this->modules=$modules;

        }
    }

    function openAll(){
        $sql="select * from app_menus order by id asc";
        $result=$db->query($sql);
        return $db->fetch_array($result);
        
    }

    function insert(){
    global $db;
    $sql="insert into app_menus values (null,'{$this->caption}',
'{$this->tool_tips}','{$this->grant_admin}',
'{$this->enabled}','{$this->icon_url}','{$this->menu_url}',
'{$this->modules}')";
    $db->query($sql);
    return mysql_insert_id();
    }

    function update(){
        global $db;
        $sql="update app_menus set caption='{$this->caption}',
tool_tips='{$this->tool_tips}',
grant_admin='{$this->grant_admin}',
enabled='{$this->enabled}',
icon_url='{$this->icon_url}',
menu_url='{$this->menu_url}',
modules='{$this->modules}'
 where id=".$this->id;
        $db->query($sql);
    }

    function delete(){
        global $db;
        $sql="delete from app_menus where id=".$this->id;
        $db->query($sql);
    }

}

?>
